<template>
    <div>
        <div>
            <a href="/" class="logo">
                <img :src="logonImg" alt=""><span>浆站信息管理</span>
            </a>
        </div>
        <div class="header-right">
            <span>欢迎您，{{username}}</span>
            <i class="iconfont icon-quit" title="退出" @click="loginout"></i>
        </div>
    </div>
</template>
<script>
import api from '@/axios/api.js'
import logonImg from 'static/img/logo.png'
    export default {
        data() {
            return {
                logonImg,
                collapse: false,
                fullscreen: false,
                name: 'linxin',
                message: 2
            }
        },
        computed:{
            username(){
                let username = localStorage.getItem('ms_username');
                return username ? username : this.name;
            }
        },
        methods:{
            loginout(){//点击退出登录
                api.loginOut().then(res=>{
                    sessionStorage.removeItem('username');
                    localStorage.removeItem('ms_username');
                    this.$router.push('/login');
                },error=>{
                    sessionStorage.removeItem('username');
                    localStorage.removeItem('ms_username');
                    this.$router.push('/login');
                })
            }
        }
    }
</script>
<style scoped>
.header-right{
    float: right;
    font-size: 14px;
    line-height: 60px;
}
.header-right .icon-quit{
    font-size: 18px;
    margin-left:10px;
    line-height: 60px;
    color:#3ac1c4;
    cursor: pointer;
}
.logo{
    float: left;
    display: block;
    line-height: 60px;
    font-size: 22px;
    overflow: hidden;
    height: 60px;
    margin-bottom:16px;
    color:#333;
}
.logo>img{
    height: 40px;
    margin:10px 8px;
    display: block;
    float: left;
}
</style>
